function getDataGenset(id) {$("#thisContent").html('Loading...').load('/aventurine_project/laporangenset/view/', {dataId: id});}
function getDataPemeriksaan(id) {$("#thisContent").html('Loading...').load('/aventurine_project/laporangenset/view/', {dataId: id});}
function getDataGensetProyek(id) {$("#thisContent").html('Loading...').load('/aventurine_project/laporangenset/view/', {dataId: id});}
function getEqualize() {$(".body, .submenu, .content, .widget").equalizeCols();}
function getCal(idProyek, idGenset){
    if(idProyek!=null) {var event = "/proyek/"+idProyek;} else if(idGenset!=null) {event = "/genset/"+idGenset;} else {event="";}
    $('#calendarContent').fullCalendar({
        events: "/aventurine_project/laporangenset/datacalendar"+event,
        loading: function(bool) {
            getEqualize();},
        eventClick: function(calEvent) {
            var id = calEvent.id;
            getDataGenset(id);
            return false;
        }
    });
}

$(document).ready(function() {
    getCal();

    $('a#cal').bind("click", function() {
        var id = $(this).attr("value");
        getDataPemeriksaan(id);
        return false;
    });

    $("table#daftarAktivitas tbody tr").bind("click", function() {
        var id = $(this).attr("id");
        var val = $(this).attr("value");
        if(id) {getDataPemeriksaan(id);}
        else if(val) { var sn = $("td#sn"+val).attr("value"); $("#thisContent").empty(); $("#thisContent").append("<div id=\"titleProyek\">Nomor Serial : "+ sn +"</div><div id=\"calendarContent\"></div>"); getCal(null,val);}
        return false;
    });

    $("div#daftarProyek").each(function() {
        $(this).click(function() {
            $("#thisContent").empty();
            var id = $(this).attr("class");
            var nama = $(this).attr("value");
            $("#thisContent").append("<div id=\"titleProyek\">"+ nama +"</div><div id=\"calendarContent\"></div>");
            getCal(id, null);
        });
    });
});
